﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using NetCoreDemo.Models;
using NetCoreDemo.Models.TestModels;
using NetCoreDemo.Services.IService;

namespace NetCoreDemo.Controllers
{
    public class HomeController : Controller
    {
        private ITestService _testService;
        public HomeController(ITestService testService)
        {
            _testService = testService;
        }
        public IActionResult Index()
        {
            var st = new Stopwatch();
            st.Start();
            var studentList = new List<Student>();
            for (var i = 0; i <= 100000; i++)
            {
                studentList.Add(new Student
                {
                    FirstMidName = "三" + i,
                    LastName = "张",
                    EnrollmentDate = DateTime.Now
                });
            }
            //_testService.SaveList(studentList);        
            ViewBag.Time = st.ElapsedMilliseconds;
            st.Restart();
            return View();
        }

        public IActionResult About()
        {
            ViewData["Message"] = "Your application description page.";

            return View();
        }

        public IActionResult Contact()
        {
            ViewData["Message"] = "Your contact page.";

            return View();
        }

        public IActionResult Error()
        {
            return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
        }
    }
}
